package com.yaodian100.ec.order.web;

import java.io.File;
import java.io.StringReader;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.betwixt.io.BeanReader;
import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.io.filefilter.PrefixFileFilter;
import org.apache.commons.lang.StringUtils;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.struts2.ServletActionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;
import com.yaodian100.core.admin.utils.AdminHelper;
import com.yaodian100.core.common.dao.impl.CommonCriteria;
import com.yaodian100.core.common.entity.SimplePager;
import com.yaodian100.core.common.exception.CoreException;
import com.yaodian100.core.common.service.BaseManager;
import com.yaodian100.core.common.service.DomainService;
import com.yaodian100.core.common.utils.DateUtil;
import com.yaodian100.core.common.utils.FileUtils;
import com.yaodian100.core.common.utils.JspUtil;
import com.yaodian100.core.common.utils.ServerValue;
import com.yaodian100.core.logger.service.CustomObjectStringConverter;
import com.yaodian100.core.logger.service.LogService;
import com.yaodian100.core.menu.entity.Menu;
import com.yaodian100.crm.workorder.service.WorkOrderService;
import com.yaodian100.ec.cobranding.entity.DPNStore;
import com.yaodian100.ec.cobranding.service.DPNService;
import com.yaodian100.ec.delivery.entity.ViewDeliveryRule;
import com.yaodian100.ec.delivery.service.DeliveryRuleService;
import com.yaodian100.ec.givebonus.entity.BonusSetting;
import com.yaodian100.ec.givebonus.service.BonusSettingService;
import com.yaodian100.ec.member.entity.Balance;
import com.yaodian100.ec.member.service.AddessService;
import com.yaodian100.ec.order.entity.OrderHistory;
import com.yaodian100.ec.order.entity.OrderProduct;
import com.yaodian100.ec.order.entity.OrderProductDetail;
import com.yaodian100.ec.order.entity.Orders;
import com.yaodian100.ec.order.entity.ServiceOrders;
import com.yaodian100.ec.order.entity.Orders.ORDER_LOGISTIC_PROVIDER_TP;
import com.yaodian100.ec.order.remote.ClientCsrUpdateOrderService;
import com.yaodian100.ec.order.service.OrderHistoryService;
import com.yaodian100.ec.order.service.OrderModifyService;
import com.yaodian100.ec.order.service.OrderService;
import com.yaodian100.ec.order.service.ServiceOrderService;
import com.yaodian100.ec.product.entity.SpecificationInventory;
import com.yaodian100.ec.product.service.ProductService;
import com.yaodian100.ec.supplierapply.entity.SupplierApply;
import com.yaodian100.ec.supplierapply.service.SupplierApplyService;

/**
 * @author jinwei.lin
 * 
 */
public class CrmUpdateOrderAction extends ActionSupport implements Preparable {

	private static final String RESULT_VIEW_ORDER_STATUS_HISTORY = "viewOrderStatusHistory";
	private static final long serialVersionUID = 178887580319281383L;
	/** logger */
	private final Logger logger = LoggerFactory.getLogger(CrmUpdateOrderAction.class);

	@Autowired
	private LogService logService;
	@Autowired
	private ProductService productService;
	@Resource
	private ServiceOrderService serviceOrderService;

	@Resource(name = "supplierApplyService")
	private SupplierApplyService supplierApplyService;
	@Resource
	private OrderModifyService orderModifyService;
	private BigDecimal codFee = new BigDecimal(0);// COD﹣收取手續費
	@Resource
	private AddessService addressService;
	@Autowired
	private DPNService dpnService;
	@Resource
	private WorkOrderService workOrderService;

	private Menu orderStMenu; // 與 getter, setter
	private Menu paymentStMenu; // 與 getter, setter
	private Menu paymentTpMenu; // 與 getter, setter
	private Menu logisticStMenu; // 與 getter, setter
	private Menu returnStMenu; // 與 getter, setter
	private Menu detailTpMenu;
	private Menu logisticCompMenu;

	private String receiverName;
	private String pop;
	private String receiverMobile;
	private String receiverPhoneArea;
	private String receiverPhone;
	private String receiverExt;
	private String receiverZip;
	private String receiverAddr;
	private String province;
	private String receiverCity;
	private String receiverArea;
	private String invoiceTitle;
	private String actionResult;
	private String orderStCode;
	private DomainService<Menu> menuService; // 與 setter
	private OrderService orderService;
	@Resource
	private OrderHistoryService orderHistoryService;
	private List<Orders> orders;
	private List<OrderProductDetail> orderProdDetail;
	private List<OrderHistory> orderHistoryList;
	private String orderId;
	private Orders order;
	private SimplePager pager;
	@Resource
	private BaseManager baseMgr;
	@Resource
	private JdbcTemplate jdbcTemplate;

	private SupplierApply supplierApply;

	private List<Orders> oldOrders;
	private String logTp;
	private String paytype;
	private String version;
	private String showCod;
	private String showPos;

	// 查詢條件
	private String orderIdParam;
	private String orderDtStParam;
	private String orderDtEdParam;
	private String loginIdParam;
	private String orderStParam;
	private String paymentStParam;
	private String paymentTpParam;
	private String domainSrcParam;
	private String minDate;
	private String today;
	private String mobile;
	private Menu domainSrc;
	private String prodIdParam;
	// private boolean hasSnapShot = false;
	private String snapShots;
	private List<ServiceOrders> cancelServiceOrders;
	private String newShipfare;
	private String storeId;
	private Map<String, String> provincesMap;
	@Autowired
	private DeliveryRuleService deliveryRuleService;
	@Autowired
	private BonusSettingService bonusSettingService;

	public Menu getDomainSrc() {
		return domainSrc;
	}

	public void setDomainSrc(Menu domainSrc) {
		this.domainSrc = domainSrc;
	}

	public String getDomainSrcParam() {
		return domainSrcParam;
	}

	public void setDomainSrcParam(String domainSrcParam) {
		this.domainSrcParam = domainSrcParam;
	}

	/**
	 * @return the mobile
	 */
	public String getMobile() {
		return mobile;
	}

	/**
	 * @param mobile the mobile to set
	 */
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String returnProductInfo() {
		return "returnProductInfo";
	}

	public String changeProductInfo() {
		return "changeProductInfo";
	}

	/**
	 * 修改发票抬头
	 * 
	 * @return
	 * @throws Exception
	 */
	public String editInvoice() throws Exception {
		if (StringUtils.isNotBlank(orderId) || order.getOrderId() != null) {
			try {
				if (null != orderId) {
					order = orderService.get(orderId);
				} else {
					this.addActionError("订单编号未输入");
					return "search";
				}
			} catch (CoreException e) {
				addActionError(e.getMessage());
				e.printStackTrace();
			}
		}
		return "editInvoice";
	}

	/**
	 * 修改收件人资料
	 * 
	 * @return
	 * @throws Exception
	 */
	public String editReceiver() throws Exception {
		HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
		HttpServletResponse response = (HttpServletResponse) ActionContext.getContext().get(
				ServletActionContext.HTTP_RESPONSE);
		if (StringUtils.isNotBlank(orderId)) {

			order = orderService.get(orderId);
			if (null != order) {
				// 地址簿-省
				provincesMap = deliveryRuleService.getOrderProvinces(orderId);
				if ("00".equals(order.getOrderSt()) || "10".equals(order.getOrderSt()) || "20".equals(order.getOrderSt())) {
					if ("30".equals(order.getReceiverTp())) {
						if (StringUtils.isNotBlank(order.getStoreId())) {

							CommonCriteria crit = new CommonCriteria();
							crit.addEq("storeId", order.getStoreId());
							List<DPNStore> DPNStores = dpnService.getDPNStoretList(crit);
							if (DPNStores.size() > 0) {
								request.setAttribute("storeAreaInit", DPNStores.get(0).getStoreArea());
							}
						}
						return "editReceiverDph";
					} else {
						return "editReceiver";
					}
				} else {
					this.addActionError("此订单编号的订单状态已不允许修改收货人讯息。可修改的订单状态为订单审核中(货到付款)，等待付款(非货到付款)，或等待配货。");
					return view();
				}
			} else {
				this.addActionError("订单编号不存在");
				return "search";
			}

		} else {
			this.addActionError("订单编号未输入");
			return "search";
		}

	}

	/**
	 * 修改付款方式
	 * 
	 * @return
	 * @throws Exception
	 */
	public String editPaymentTp() throws Exception {
		showCod = "false";
		showPos = "N";
		if (StringUtils.isNotBlank(orderId)) {
			order = orderService.get(orderId);
			codFee = addressService.getCodFee();
			if (null != order) {
				if ("00".equals(order.getOrderSt()) || "10".equals(order.getOrderSt())) {
					// 限制cod付款
					if (ORDER_LOGISTIC_PROVIDER_TP.NOT_COD_PROVIDER.getValue().equals(order.getLogisticProviderTp())) {
						showCod = "false";
						showPos = "N";
					} else {
						ViewDeliveryRule viewDeliveryRule = deliveryRuleService.canUseCodByOrderId(orderId);
						if ("Y".equals(viewDeliveryRule.getIsCod()) || "Y".equals(viewDeliveryRule.getIsPos())) {
							showCod = "true";
						}
						if ("Y".equals(viewDeliveryRule.getIsPos())) {
							showPos = "Y";
						}
					}
					return "editPaymentTp";
				} else {
					this.addActionError("此订单编号的订单状态已不允许修改支付方式。可修改的订单状态为订单审核中(货到付款)，或等待付款(非货到付款)。");
					return view();
				}

			} else {
				this.addActionError("订单编号不存在");
				return "search";
			}
		} else {
			this.addActionError("订单编号未输入");
			return "search";
		}

	}

	public String getInvoiceTitle() {
		return invoiceTitle;
	}

	public String getLoginIdParam() {
		return loginIdParam;
	}

	public Menu getLogisticStMenu() {
		return logisticStMenu;
	}

	public String getMinDate() {
		return minDate;
	}

	public Orders getOrder() {
		return order;
	}

	public String getOrderDtEdParam() {
		return orderDtEdParam;
	}

	public String getOrderDtStParam() {
		return orderDtStParam;
	}

	public String getOrderId() {
		return orderId;
	}

	public String getOrderIdParam() {
		return orderIdParam;
	}

	public List<OrderProductDetail> getOrderProdDetail() {
		return orderProdDetail;
	}

	public List<Orders> getOrders() {
		return orders;
	}

	public Menu getOrderStMenu() {
		return orderStMenu;
	}

	public String getOrderStParam() {
		return orderStParam;
	}

	public SimplePager getPager() {
		return pager;
	}

	public Menu getPaymentStMenu() {
		return paymentStMenu;
	}

	public String getPaymentStParam() {
		return paymentStParam;
	}

	public Menu getPaymentTpMenu() {
		return paymentTpMenu;
	}

	public String getReceiverAddr() {
		return receiverAddr;
	}

	public String getReceiverCity() {
		return receiverCity;
	}

	public String getReceiverExt() {
		return receiverExt;
	}

	public String getReceiverMobile() {
		return receiverMobile;
	}

	public String getReceiverName() {
		return receiverName;
	}

	public String getReceiverPhone() {
		return receiverPhone;
	}

	public String getReceiverPhoneArea() {
		return receiverPhoneArea;
	}

	public String getReceiverZip() {
		return receiverZip;
	}

	public Menu getReturnStMenu() {
		return returnStMenu;
	}

	public String getToday() {
		return today;
	}

	/**
	 * 檢視订单資料(dialog, 沒套tiles)
	 * 
	 * @return
	 * @throws Exception
	 */
	public String popView() throws Exception {
		pop = "pop";
		view();
		return "popView";
	}

	public String fixInfo() {
		return "fixInfo";
	}

	public void prepare() throws Exception {
		clearErrorsAndMessages();
		if (org.apache.commons.lang.StringUtils.isBlank(orderDtStParam)) {
			orderDtStParam = DateUtil.convertDateToString("yyyy-MM-dd", DateUtil.getTodayAddDays(-7).getTime());
		}
		if (org.apache.commons.lang.StringUtils.isBlank(orderDtEdParam)) {
			orderDtEdParam = DateUtil.convertDateToString("yyyy-MM-dd", DateUtil.getToday().getTime());
		}
		if (StringUtils.isBlank(minDate)) {
			minDate = DateUtil.convertDateToString("yyyy,MM - 1,dd", DateUtil.getTodayAddDays(-60).getTime());
		}
		today = DateUtil.convertDateToString("yyyy,MM - 1,dd", DateUtil.getToday().getTime());
		if (orderStMenu == null) {
			orderStMenu = menuService.get("Order.status.md");
		}
		if (logisticStMenu == null) {
			logisticStMenu = menuService.get("Order.Prod.LogisticSt");
		}
		if (paymentStMenu == null) {
			paymentStMenu = menuService.get("Order.paymentSt");
		}
		if (paymentTpMenu == null) {
			paymentTpMenu = menuService.get("Order.PaymentTp");
		}
		if (returnStMenu == null) {
			returnStMenu = menuService.get("Order.Prod.ReturnSt");
		}
		if (detailTpMenu == null) {
			detailTpMenu = menuService.get("Product.Type");
		}
		if (null == domainSrc) {
			domainSrc = menuService.get("Site.domain");
		}

		if (null == logisticCompMenu) {
			logisticCompMenu = menuService.get("Logistic.company");
		}
	}

	/**
	 * 订单資料列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public String query() throws Exception {
		CommonCriteria crit = new CommonCriteria();

		if (StringUtils.isBlank(orderDtStParam)) {
			orderDtStParam = DateUtil.convertDateToString("yyyy-MM-dd", DateUtil.getTodayAddDays(-7).getTime());
		}
		if (StringUtils.isBlank(orderDtEdParam)) {
			orderDtEdParam = DateUtil.convertDateToString("yyyy-MM-dd", DateUtil.getToday().getTime());
		}

		DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		crit.addGe("orderDt", format.parse(orderDtStParam + " 00:00:00"));
		crit.addLe("orderDt", format.parse(orderDtEdParam + " 23:59:59"));
		if (StringUtils.isNotBlank(mobile)) {
			crit.addEq("receiverMobile", mobile);
		}
		if (StringUtils.isNotBlank(orderIdParam)) {
			crit.addRlike("orderId", orderIdParam.trim());
		}
		if (StringUtils.isNotBlank(loginIdParam)) {
			crit.addRlike("loginId", loginIdParam.trim());
		}
		if (StringUtils.isNotBlank(orderStParam)) {
			crit.addEq("orderSt", orderStParam);
		}
		if (StringUtils.isNotBlank(paymentStParam)) {
			crit.addEq("paymentSt", paymentStParam);
		}
		if (StringUtils.isNotBlank(paymentTpParam)) {
			crit.addEq("paymentTp", paymentTpParam);
		}

		if (StringUtils.isNotBlank(domainSrcParam)) {
			crit.addEq("domainSrc", domainSrcParam);
		}

		if (StringUtils.isNotBlank(prodIdParam)) {

			String sql = "select a.order_id from ec_order_main a, ec_order_product b where a.order_id = b.order_id and b.prod_id = ? and to_char(a.order_dt,'yyyymmdd') >= ? and to_char(a.order_dt,'yyyymmdd') <= ?";
			List<Map<String, Object>> orderList = jdbcTemplate.queryForList(sql, prodIdParam, StringUtils.replace(
					orderDtStParam, "-", ""), StringUtils.replace(orderDtEdParam, "-", ""));
			ArrayList<String> orderContainThisProd = new ArrayList<String>();
			for (Iterator<Map<String, Object>> orders = orderList.iterator(); orders.hasNext();) {
				Map<String, Object> order = orders.next();
				String orderId = (String) order.get("order_id");
				orderContainThisProd.add(orderId);

			}

			if (orderContainThisProd.size() > 0) {
				crit.addIn("orderId", orderContainThisProd);
			} else {
				orderContainThisProd.add("");
				crit.addIn("orderId", orderContainThisProd);
			}
		}

		if (pager == null) {
			pager = new SimplePager();
		}
		// pager.setPageRecord(1);
		int entitySize = orderService.getListSize(crit).intValue();
		pager.setTotalSize(entitySize);

		orders = orderService.getList(pager.getCurrentPage() * pager.getPageRecord(), pager.getPageRecord(), crit, null);
		// logger.info("pager:{},orders:{}", pager, orders);

		return "list";
	}

	/**
	 * 查询
	 * 
	 * @return
	 * @throws Exception
	 */
	public String search() throws Exception {
		setDomainSrcParam(ServerValue.getFrontHostname().substring(7));
		return "search";
	}

	public void setInvoiceTitle(String invoiceTitle) {
		this.invoiceTitle = invoiceTitle;
	}

	public void setLoginIdParam(String loginIdParam) {
		this.loginIdParam = loginIdParam;
	}

	public void setLogisticStMenu(Menu logisticStMenu) {
		this.logisticStMenu = logisticStMenu;
	}

	public void setMenuService(DomainService<Menu> menuService) {
		this.menuService = menuService;
	}

	public void setMinDate(String minDate) {
		this.minDate = minDate;
	}

	public void setOrder(Orders order) {
		this.order = order;
	}

	public void setOrderDtEdParam(String orderDtEdParam) {
		this.orderDtEdParam = orderDtEdParam;
	}

	public void setOrderDtStParam(String orderDtStParam) {
		this.orderDtStParam = orderDtStParam;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public void setOrderIdParam(String orderIdParam) {
		this.orderIdParam = orderIdParam;
	}

	public void setOrderProdDetail(List<OrderProductDetail> orderProdDetail) {
		this.orderProdDetail = orderProdDetail;
	}

	public void setOrders(List<Orders> orders) {
		this.orders = orders;
	}

	public void setOrderService(OrderService orderService) {
		this.orderService = orderService;
	}

	public void setOrderStMenu(Menu orderStMenu) {
		this.orderStMenu = orderStMenu;
	}

	public void setOrderStParam(String orderStParam) {
		this.orderStParam = orderStParam;
	}

	public void setPager(SimplePager pager) {
		this.pager = pager;
	}

	public void setPaymentStMenu(Menu paymentStMenu) {
		this.paymentStMenu = paymentStMenu;
	}

	public void setPaymentStParam(String paymentStParam) {
		this.paymentStParam = paymentStParam;
	}

	public void setPaymentTpMenu(Menu paymentTpMenu) {
		this.paymentTpMenu = paymentTpMenu;
	}

	public void setReceiverAddr(String receiverAddr) {
		this.receiverAddr = receiverAddr;
	}

	public void setReceiverCity(String receiverCity) {
		this.receiverCity = receiverCity;
	}

	public void setReceiverExt(String receiverExt) {
		this.receiverExt = receiverExt;
	}

	public void setReceiverMobile(String receiverMobile) {
		this.receiverMobile = receiverMobile;
	}

	public void setReceiverName(String receiverName) {
		this.receiverName = receiverName;
	}

	public void setReceiverPhone(String receiverPhone) {
		this.receiverPhone = receiverPhone;
	}

	public void setReceiverPhoneArea(String receiverPhoneArea) {
		this.receiverPhoneArea = receiverPhoneArea;
	}

	public void setReceiverZip(String receiverZip) {
		this.receiverZip = receiverZip;
	}

	public void setReturnStMenu(Menu returnStMenu) {
		this.returnStMenu = returnStMenu;
	}

	public void setToday(String today) {
		this.today = today;
	}

	/**
	 * 更新发票抬头
	 * 
	 * @return
	 * @throws Exception
	 */
	public String updateInvoice() throws Exception {
		if (StringUtils.isNotBlank(orderId) || order.getOrderId() != null) {
			try {
				if (null != orderId) {
					order = orderService.get(orderId);
					order.setInvoiceTitle(invoiceTitle);
					orderService.updateOrder(order, "异常发票资料");
					logService.save("orderAction", "updateInvoice", order);
				} else {
					this.addActionError("订单编号未输入");
					return "editReceiver";
				}
			} catch (CoreException e) {
				addActionError(e.getMessage());
				e.printStackTrace();
			}
		}
		if ("pop".equals(pop)) {
			return popView();
		} else {
			return view();
		}
	}

	/**
	 * 更新收件人
	 * 
	 * @return
	 * @throws Exception
	 */
	public String updateReceiver() throws Exception {
		if (StringUtils.isNotBlank(orderId)) {
			try {

				Orders order = orderModifyService.get(orderId);
				if (null != order) {
					Map<String, Object> attrs = new HashMap<String, Object>();
					attrs.put("contactName", receiverName);
					attrs.put("areaCode", receiverPhoneArea);
					attrs.put("phone", receiverPhone);
					attrs.put("extension", receiverExt);
					attrs.put("mobile", mobile);

					boolean canChangeAddr = false;

					if ("30".equals(order.getPaymentTp()) || "60".equals(order.getPaymentTp())) {
						if ("00".equals(order.getOrderSt()) || ("20".equals(order.getOrderSt()) && !order.isSync())) {
							canChangeAddr = true;
						}
					} else {
						if ("00".equals(order.getPaymentSt()) && "10".equals(order.getOrderSt())) {
							canChangeAddr = true;
						}
					}

					if (canChangeAddr) {
						attrs.put("province", province);
						attrs.put("city", receiverCity);

						attrs.put("addr", receiverAddr);
						attrs.put("midend", true);
						if ("30".equals(order.getReceiverTp())) {// 達芙妮
							attrs.put("district", receiverArea);
							attrs.put("storeId", storeId);
						} else {
							attrs.put("zipCode", receiverZip);
							receiverArea = receiverArea.split(",")[0];
							if (receiverArea.substring(0, 1).equals("※")) {
								receiverArea = receiverArea.substring(1);
							}
							attrs.put("district", receiverArea);
							attrs.put("version", version);
						}
					}

					orderModifyService.updateOrderAddres(orderId, attrs);
				} else {
					this.addActionError("订单编号不存在");
					return "search";
				}

			} catch (CoreException e) {
				if (orderModifyService.ERROR_ORDER_MODIFY_ADDRESS_Y1020N1020.equals(e.getLocalizedMessage())) {
					this.addActionError("商品发货处理中，无法修改订单");
				} else if (orderModifyService.ERROR_ORDER_MODIFY_ADDRESS_Y1020N1020_MIDEND.equals(e.getLocalizedMessage())) {
					this.addActionError("商品发货处理中，无法修改订单");
				} else if (orderModifyService.ERROR_ORDER_MODIFY_ADDRESS_Y3060N0020.equals(e.getLocalizedMessage())) {
					this.addActionError("商品发货处理中，无法修改订单");
				} else if (orderModifyService.ERROR_ORDER_MODIFY_ADDRESS_Y40N20.equals(e.getLocalizedMessage())) {
					this.addActionError("商品发货处理中，无法修改订单");
				} else if (orderModifyService.ERROR_ORDER_MODIFY_ADDRESS_Y50N1020.equals(e.getLocalizedMessage())) {
					this.addActionError("商品发货处理中，无法修改订单");
				} else {
					this.addActionError("订单修改遭遇无法遇期的错误");
				}
				e.printStackTrace();
			}
		} else {
			this.addActionError("订单编号未输入");
			return "search";
		}
		if ("pop".equals(pop)) {
			return popView();
		} else {
			return view();
		}
	}

	/**
	 * 檢視订单資料
	 * 
	 * @return
	 */
	public String view() throws Exception {
		if (StringUtils.isNotBlank(orderId)) {
			try {
				// order = orderService.get(orderId);
				// if (orderProdDetail != null) {
				// orderProdDetail = new ArrayList<OrderProductDetail>();
				// orderProdDetail.clear();
				// }else
				// orderProdDetail = new ArrayList<OrderProductDetail>();
				//				
				// for (OrderProduct op : order.getOrderProduct()) {
				// orderProdDetail.addAll(op.getOrderProductDetail());
				// }

				// logService.save(getClass().getSimpleName(), "view", theO);
				order = (Orders) baseMgr.get(Orders.class, orderId);
				if (StringUtils.isNotBlank(order.getScmSupplierId())) {
					supplierApply = supplierApplyService.get(order.getScmSupplierId());
					setSupplierApply(supplierApply);
				} else {
					supplierApply = new SupplierApply();
					setSupplierApply(supplierApply);
				}

				IOFileFilter fileFilter = new PrefixFileFilter(orderId + "_");
				IOFileFilter dirFilter = null;

				String memberId = order.getMemberId();
				String snapShotFolder = ServerValue.getMidHtmlPath() + "member" + File.separatorChar + memberId.substring(0, 4)
						+ File.separatorChar + memberId.substring(4, 8) + File.separatorChar + memberId + File.separatorChar;
				if (new File(snapShotFolder).exists()) {
					Iterator c = FileUtils.iterateFiles(new File(snapShotFolder), fileFilter, dirFilter);
					String tempStr = "";
					while (c.hasNext()) {
						// hasSnapShot = true;
						File snapShot = (File) c.next();
						String productId = snapShot.getName().split("_")[1];
						tempStr += "," + productId;
					}
					if (tempStr.length() > 8) {
						snapShots = tempStr.substring(1);
					} else {
						snapShots = "";
					}
				}
				if (order.getOrderSt().startsWith("8")) {
					CommonCriteria cc = new CommonCriteria();
					cc.addEq("orderId", order.getOrderId());
					cc.addEq("srcType", 3);
					cancelServiceOrders = serviceOrderService.getList(0, -1, cc, new String[] { "serviceId" });

				} else {
					cancelServiceOrders = null;
				}
			} catch (CoreException e) {
				addActionError(e.getMessage());
				e.printStackTrace();
			}
		}
		return "view";
	}

	/**
	 * 更新狀態
	 * 
	 * @param orderId
	 * @return
	 * @throws CoreException
	 */
	public String updOrdSt() throws CoreException {
		if (true == orderService.updateOrderSt(orderId, orderStCode)) {
			if ("82".equals(orderStCode)) {
				Orders thisOrder = orderService.get(orderId);
				// 退還數量
				for (OrderProduct op : thisOrder.getOrderProduct()) {
					for (OrderProductDetail opd : op.getOrderProductDetail()) {
						CommonCriteria cc = new CommonCriteria();
						cc.addEq("specId", Long.parseLong(opd.getProdSpecId()));
						cc.addEq("productId", opd.getProdId());

						List<SpecificationInventory> si = productService.getSpecificationInventory(cc);
						for (SpecificationInventory entity : si) {
							entity.setCancelInventory(entity.getCancelInventory() + opd.getQty());
							productService.saveSpecificationInventory(entity);
						}
					}
				}
				// 退還已付款金額
				serviceOrderService.cancelOrderBySystem(orderId, "订单" + thisOrder.getOrderId() + " 审核失败，系统已取消该笔订单", "其它",
						thisOrder.getMemberId(), ServletActionContext.getRequest().getRemoteAddr(), thisOrder.getB2eId());
				// 寄信

				serviceOrderService.sendMail("order.cancelOrderOnVerify", "订单" + thisOrder.getOrderId() + " 审核失败，系统已取消该笔订单",
						thisOrder);
				orderService.updateOrderSt(orderId, orderStCode);
			}
			actionResult = "success";
		} else {
			actionResult = "update error!";
		}
		return "update_st";
	}

	public String viewChangeLog() {
		try {
			oldOrders = new ArrayList<Orders>();
			order = orderService.get(orderId);
			String xml = "";
			String sql = "select log_message, create_date, create_user  from comm_log_order where order_id= ? and service_method = ? order by create_date desc";

			List<Map<String, Object>> data = jdbcTemplate.queryForList(sql, orderId, logTp);
			for (Iterator<Map<String, Object>> rows = data.iterator(); rows.hasNext();) {
				Map<String, Object> row = rows.next();
				xml = (String) row.get("log_message");
				Date createDt = (Date) row.get("create_date");
				String createUser = (String) row.get("create_user");

				StringReader xmlReader = new StringReader(xml);

				BeanReader beanReader = new BeanReader();
				beanReader.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(false);
				beanReader.getXMLIntrospector().getConfiguration().setWrapCollectionsInElement(false);
				beanReader.getBindingConfiguration().setMapIDs(false);
				beanReader.getBindingConfiguration().setObjectStringConverter(new CustomObjectStringConverter());

				// Orders orders = (Orders)XMLUtils.(xmlReader, Orders.class);

				beanReader.registerBeanClass("Orders", Orders.class);
				Orders oldOrder = (Orders) beanReader.parse(xmlReader);
				oldOrder.setCreateDate(createDt); // 不使用原本order的，而是用log的
				oldOrder.setCreateUser(createUser);

				oldOrders.add(oldOrder);

			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return "viewChangeLog";
	}

	public String viewOrderStatusHistory() {
		String orderId = this.orderId;
		List<OrderHistory> orderHistoryQueryResult = this.orderHistoryService.getOrderHistory(orderId);
		setOrderHistoryList(orderHistoryQueryResult);
		return RESULT_VIEW_ORDER_STATUS_HISTORY;
	}

	private void lockOrderForUpdate(String orderId) {
		try {
			JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
			factory.setServiceClass(ClientCsrUpdateOrderService.class);
			factory.setAddress(ServerValue.getCsrLockOrderWS());
			ClientCsrUpdateOrderService client = (ClientCsrUpdateOrderService) factory.create();
			String result = client.doPartialCancelBlock(orderId);
			orderService.lockOrderForUpdate(orderId, result);
		} catch (RuntimeException e) {
			throw new RuntimeException("订单已锁定！");
		}
	}

	public String toUpdateOrderAndShipfare() {
		try {
			view();
			lockOrderForUpdate(orderId);

		} catch (RuntimeException e) {
			errMsg = e.getMessage();

		} catch (Exception e) {
			errMsg = e.getMessage();

		}
		return "toUpdateOrderAndShipfare";
	}

	private String errMsg;
	private String receiverProvince;
	private String weightSum;
	// amount+discount
	private String orderPrice;
	private float shipfare;
	private String orderDiscount;

	public String getFreight() {
		logger.info("orderDiscount:{}", orderDiscount);
		BigDecimal shipfare = addressService.getFreight(JspUtil.urlDecoding(receiverProvince, "UTF-8"), BigDecimal
				.valueOf(Float.valueOf(weightSum)), BigDecimal.valueOf(Float.valueOf(orderPrice)), BigDecimal.valueOf(Float
				.valueOf(orderDiscount)));
		this.shipfare = shipfare.floatValue();
		return "getFreight";
	}

	private String totalPrice;
	private int bonus;

	public String calBonus() {
		Orders order = (Orders) baseMgr.get(Orders.class, orderId);
		Balance balance = (Balance) baseMgr.get(Balance.class, order.getMemberId());
		BigDecimal iOffsetBonus = orderService.calcOffsetBonus(order.getDomainSrc(), order.getChannel(), balance,
				new BigDecimal(totalPrice));
		bonus = iOffsetBonus.intValue();
		return "getBonus";
	}

	private float calBonus(float totalPrice) {
		BigDecimal pageTotalPrice = BigDecimal.valueOf(totalPrice);
		BonusSetting bonusSetting = bonusSettingService.getLowestDiscount(pageTotalPrice);
		if (null == bonusSetting) {
			bonusSetting = new BonusSetting();
			bonusSetting.setDiscountLimit(BigDecimal.valueOf(200));
			bonusSetting.setPercentage(BigDecimal.valueOf(10));
		}
		BigDecimal perc = bonusSetting.getPercentage();
		perc = perc.divide(BigDecimal.valueOf(100));
		BigDecimal theBonus = BigDecimal.valueOf(pageTotalPrice.floatValue() * perc.floatValue());
		if (theBonus.compareTo(bonusSetting.getDiscountLimit()) == 1 && bonusSetting.getDiscountLimit().intValue() > 0) {
			theBonus = bonusSetting.getDiscountLimit();
		}
		return theBonus.floatValue();
	}

	private String[] cancelProduct;
	private String canLockOrder = "false";

	/**
	 * @return the canLockOrder
	 */
	public String getCanLockOrder() {
		return canLockOrder;
	}

	/**
	 * @param canLockOrder the canLockOrder to set
	 */
	public void setCanLockOrder(String canLockOrder) {
		this.canLockOrder = canLockOrder;
	}

	public String askOrderForUpdate() {
		try {
			//
			JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
			factory.setServiceClass(ClientCsrUpdateOrderService.class);
			factory.setAddress(ServerValue.getCsrLockOrderWS());
			ClientCsrUpdateOrderService client = (ClientCsrUpdateOrderService) factory.create();

			String result = client.checkAllowPartialCancelBlock(orderId);
			if ("true".equals(result)) {
				canLockOrder = "true";
			} else {
				canLockOrder = result;
			}
		} catch (Exception e) {
			canLockOrder = "系统忙碌中...";
			e.printStackTrace();
		}
		return "askOrderForUpdate";
	}

	public String updateOrderAndShipfare() {
		try {
			Orders order = (Orders) baseMgr.get(Orders.class, orderId);
			if (!order.getOrderSt().equals(Orders.ORDER_ST.DELIVER_PROCESSING.getValue())) {
				throw new RuntimeException("This Order cann't be modify!");
			}
			Object[] orderProducts = baseMgr.queryByHql("from OrderProduct where orderId=?", new Object[] { orderId });
			Orders newOrder = new Orders();
			BeanUtils.copyProperties(order, newOrder);
			newOrder.setOrderId(null);
			newOrder.setOrderProduct(new ArrayList<OrderProduct>());
			BigDecimal cancelAmount = BigDecimal.ZERO;
			BigDecimal cancelDiscount = BigDecimal.ZERO;
			BigDecimal cancelCoupon = BigDecimal.ZERO;
			float cancelWeight = 0;
			BigDecimal cancelInstallmentFee = BigDecimal.ZERO;
			List<OrderProduct> cancelProducts = new ArrayList<OrderProduct>();
			Map<String, String> prodCanUseCodMap = deliveryRuleService.orderDetailCanUseCodMap(order.getOrderId());
			// orderProduct
			for (Object obj : orderProducts) {
				OrderProduct theOp = (OrderProduct) obj;
				boolean canceled = false;
				for (String cancelData : cancelProduct) {
					String[] dataSplit = cancelData.split("_");
					String orderProdId = dataSplit[0];
					/*
					 * float amount = Float.valueOf(dataSplit[1]); float discount = Float.valueOf(dataSplit[2]); float coupon =
					 * Float.valueOf(dataSplit[3]);
					 */

					if (theOp.getOrderProdId().longValue() == Long.valueOf(orderProdId)) {
						canceled = true;
					}
				}
				if (canceled) {
					cancelProducts.add(theOp);
					cancelAmount = cancelAmount.add(theOp.getAmount());
					cancelDiscount = cancelDiscount.add(theOp.getDiscount());
					cancelCoupon = cancelCoupon.add(theOp.getCoupon());
					if (order.getInstallmentFee() != null) {
						cancelInstallmentFee = cancelInstallmentFee.add(theOp.getInstallmentFee());
					}
					for (OrderProductDetail theOpd : theOp.getOrderProductDetail()) {
						cancelWeight += theOpd.getUnitWeight().floatValue() * theOpd.getQty();
					}
					// 取消的商品，不存入新订单内
					continue;
				}

				OrderProduct newOp = new OrderProduct();
				List<OrderProductDetail> opds = theOp.getOrderProductDetail();
				// theOp.setOrderProductDetail(null);
				// theOp.setOrder(null);
				try {
					BeanUtils.copyProperties(theOp, newOp);
					newOp.setOrder(null);
					newOp.setShipfare(BigDecimal.ZERO);
					newOp.setOrderProductDetail(null);
				} catch (RuntimeException re) {
					re.printStackTrace();
				}
				newOp.setOrder(newOrder);
				newOp.setOrderProductDetail(new ArrayList<OrderProductDetail>());
				for (OrderProductDetail opd : opds) {
					OrderProductDetail newOpd = new OrderProductDetail();
					BeanUtils.copyProperties(opd, newOpd);
					newOpd.setOrder(newOrder);
					newOpd.setOrderProd(newOp);
					newOpd.setShipfare(BigDecimal.ZERO);
					if (null == prodCanUseCodMap.get(newOpd.getProdId())
							|| StringUtils.isBlank(prodCanUseCodMap.get(newOpd.getProdId()))) {
						newOpd.setCanUseCod("Y");
					} else {
						newOpd.setCanUseCod(prodCanUseCodMap.get(newOpd.getProdId()).split(",")[1]);
					}
					newOp.getOrderProductDetail().add(newOpd);
				}
				newOrder.getOrderProduct().add(newOp);
			}
			if (newOrder.getOrderProduct() == null || newOrder.getOrderProduct().size() == 0) {
				throw new RuntimeException("This order has no order product!!");
			}
			newOrder.setApplyCampaigns(null);

			newOrder.setAmount(null);
			newOrder.setDiscount(BigDecimal.ZERO);
			newOrder.setCoupon(BigDecimal.ZERO);
			newOrder.setBonus(BigDecimal.ZERO);
			newOrder.setCash(BigDecimal.ZERO);
			newOrder.setMustPay(BigDecimal.ZERO);
			newOrder.setMyWallet(BigDecimal.ZERO);
			newOrder.setShipfare(BigDecimal.ZERO);
			newOrder.setTotalPrice(BigDecimal.ZERO);
			newOrder.setTotalWeight(BigDecimal.ZERO);
			newOrder.setGiftcardBalance(BigDecimal.ZERO);
			newOrder.setGiftcardBalanceShipfare(BigDecimal.ZERO);
			newOrder.setSync(false);
			newOrder.setOrgOrderId(order.getOrderId());

			int dot = 1;
			if (StringUtils.isNotBlank(order.getOuterOrderId())) {
				dot = 2;
			}
			// 设定订单金额
			BigDecimal theAmount = order.getAmount().subtract(cancelAmount);
			BigDecimal theDiscount = order.getDiscount().subtract(cancelDiscount);
			BigDecimal theCoupon = order.getCoupon().subtract(cancelCoupon);
			BigDecimal theInstallmentFee = BigDecimal.ZERO;
			if (order.getInstallmentFee() != null) {
				theInstallmentFee = order.getInstallmentFee().subtract(cancelInstallmentFee);
			}
			// newOrder.setAmount(BigDecimal.valueOf(theAmount));
			newOrder.setDiscount(theDiscount.setScale(dot, RoundingMode.DOWN));
			newOrder.setCoupon(theCoupon.setScale(dot, RoundingMode.DOWN));
			newOrder.setInstallmentFee(theInstallmentFee.setScale(dot, RoundingMode.DOWN));

			newOrder.setOrderDt(new Date());
			newOrder.setTotalWeight(order.getTotalWeight().subtract(BigDecimal.valueOf(cancelWeight)).setScale(dot,
					RoundingMode.DOWN));
			BigDecimal theTotalPrice = theAmount.add(newOrder.getDiscount()).add(newOrder.getCoupon());

			// 付款期限：線上支付: 72hr; 匯款/ATM/郵區 : 7x24 hr
			if (Orders.ORDER_PAYMENT_TYPE.BANK.getValue().equals(order.getPaymentTp())
					|| Orders.ORDER_PAYMENT_TYPE.POST.getValue().equals(order.getPaymentTp())
					|| Orders.ORDER_PAYMENT_TYPE.ARRIVE.getValue().equals(order.getPaymentTp())
					|| Orders.ORDER_PAYMENT_TYPE.ARRIVE_CARD.getValue().equals(order.getPaymentTp())) {
				Date dead7 = DateUtil.getTodayAddDays(7).getTime();
				dead7 = DateUtil.getLastTimestamp(Calendar.HOUR_OF_DAY, dead7);
				newOrder.setDeadline(dead7);
			} else {
				Date dead1 = DateUtil.getTodayAddDays(1).getTime();
				dead1 = DateUtil.getLastTimestamp(Calendar.HOUR_OF_DAY, dead1);
				newOrder.setDeadline(dead1);
			}

			newOrder.setTotalPrice(theTotalPrice);
			float theShipfare = Float.valueOf(newShipfare);
			if (theShipfare < 0) {
				theShipfare = 0;
			}
			newOrder.setShipfare(BigDecimal.valueOf(theShipfare).setScale(dot, RoundingMode.DOWN));
			// 计算积分折抵上限(订单商品总额-discount)
			if (order.getBonus().compareTo(BigDecimal.ZERO) == 1) {
				Balance balance = (Balance) baseMgr.get(Balance.class, newOrder.getMemberId());
				BigDecimal orderPrice = newOrder.getTotalPrice().subtract(newOrder.getDiscount());
				BigDecimal theBonus = orderService.calcOffsetBonus(newOrder.getDomainSrc(), newOrder.getChannel(), balance,
						orderPrice);
				if (theBonus.compareTo(order.getBonus()) == 1) {
					theBonus = order.getBonus();
				}
				newOrder.setBonus(theBonus);
			}
			// 原订单－－＞礼品卡+账户余额
			BigDecimal orgOrderGiftcardBalance = order.getGiftcardBalance();
			BigDecimal orgOrderMyWallet = BigDecimal.ZERO;
			if (order.getPaymentSt().equals("10")) {
				orgOrderMyWallet = order.getMyWallet().add(order.getCash());
			} else {
				orgOrderMyWallet = order.getMyWallet();
			}
			// 新訂單的totalprice
			BigDecimal orderTotalPrice = newOrder.getAmount().subtract(newOrder.getBonus()).add(newOrder.getShipfare()).add(
					newOrder.getCodFee()).add(newOrder.getInstallmentFee());

			// 先用原始礼品卡余额支付新訂單金額
			if (orgOrderGiftcardBalance.compareTo(BigDecimal.ZERO) == 1) {
				if (orgOrderGiftcardBalance.compareTo(orderTotalPrice) == 1) {
					newOrder.setGiftcardBalance(orderTotalPrice.setScale(dot, RoundingMode.DOWN));
				} else {
					newOrder.setGiftcardBalance(orgOrderGiftcardBalance.setScale(dot, RoundingMode.DOWN));
				}
			} else {
				newOrder.setGiftcardBalance(BigDecimal.ZERO);
			}

			// 再用账户余额支付
			if (orderTotalPrice.subtract(orgOrderGiftcardBalance).compareTo(BigDecimal.ZERO) == 1) {
				if (orgOrderMyWallet.compareTo(orderTotalPrice.subtract(orgOrderGiftcardBalance)) == 1) {
					newOrder.setMyWallet(orderTotalPrice.subtract(orgOrderGiftcardBalance).setScale(1, RoundingMode.DOWN));
				} else {
					newOrder.setMyWallet(orgOrderMyWallet.setScale(dot, RoundingMode.DOWN));
				}
			} else {
				newOrder.setMyWallet(BigDecimal.ZERO);
			}
			// mustPay
			newOrder.setMustPay(orderTotalPrice.subtract(newOrder.getMyWallet()).subtract(newOrder.getGiftcardBalance()));

			BigDecimal tmpBalance = orgOrderMyWallet.add(orgOrderGiftcardBalance);// 原始帳戶餘額+禮品卡
			if (tmpBalance.compareTo(orderTotalPrice) == 1) {// 原订单金额足够支付新订单金额
				newOrder.setPaymentTp(Orders.ORDER_PAYMENT_TYPE.MY_WALLET.getValue());
				newOrder.setPaymentSt("10");
				newOrder.setPaymentDt(new Date());
				newOrder.setSyncDt(new Date());
				newOrder.setOrderSt(Orders.ORDER_ST.WAIT_FOR_DELIVER.getValue());
			} else {// 原订单金额不足以支付新订单金额
				newOrder.setPaymentSt("00");
				newOrder.setPaymentDt(null);
				if (Orders.ORDER_PAYMENT_TYPE.ARRIVE.getValue().equals(newOrder.getPaymentTp())
						|| Orders.ORDER_PAYMENT_TYPE.ARRIVE_CARD.getValue().equals(newOrder.getPaymentTp())) {
					// 若為cod，則直接同步後台，不用等付款
					newOrder.setOrderSt(Orders.ORDER_ST.WAIT_FOR_DELIVER.getValue());
				} else {
					newOrder.setOrderSt(Orders.ORDER_ST.ORDER_CREATE.getValue());
				}
				// 若为账户余额付款，預設付款方式為線上支付（再透過中台修改付款方式）
				if (order.getPaymentTp().equals(Orders.ORDER_PAYMENT_TYPE.MY_WALLET.getValue())) {
					newOrder.setPaymentTp(Orders.ORDER_PAYMENT_TYPE.ONLINE.getValue());
				}
			}
			HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(
					ServletActionContext.HTTP_REQUEST);

			String host = request.getHeader("X-Forwarded-For");
			if (StringUtils.isBlank(host)) {
				host = StringUtils.defaultString(request.getRemoteAddr(), "0.0.0.0");
			} else if (host.length() > 100) {
				host = host.substring(0, 100);
			}
			String b2eId = "";
			newOrder.setCreateDate(new Date());
			newOrder.setOrderDt(newOrder.getCreateDate());
			orderService.csrUpdateOrderAndShipfare(order, newOrder, AdminHelper.getUserDetails().getUsername(), host, b2eId,
					cancelProducts);
			request.setAttribute("order", newOrder);
			request.setAttribute("newOrder", newOrder);
			domainId = workOrderService.closeOrderForPartialCancelOrder(order.getOrderId(), AdminHelper.getUserDetails()
					.getUsername());
		} catch (RuntimeException re) {
			re.printStackTrace();

			throw re;
		}
		if (domainId == null) {
			return "updateOrderAndShipfare";
		} else {
			return "workOrderList";
		}
	}

	private String domainId;

	/**
	 * @return the domainId
	 */
	public String getDomainId() {
		return domainId;
	}

	/**
	 * @param domainId the domainId to set
	 */
	public void setDomainId(String domainId) {
		this.domainId = domainId;
	}

	/**
	 * @return the cancelProduct
	 */
	public String[] getCancelProduct() {
		return cancelProduct;
	}

	/**
	 * @param cancelProduct the cancelProduct to set
	 */
	public void setCancelProduct(String[] cancelProduct) {
		this.cancelProduct = cancelProduct;
	}

	/**
	 * @return the totalPrice
	 */
	public String getTotalPrice() {
		return totalPrice;
	}

	/**
	 * @param totalPrice the totalPrice to set
	 */
	public void setTotalPrice(String totalPrice) {
		this.totalPrice = totalPrice;
	}

	/**
	 * @param bonus the bonus to set
	 */
	public void setBonus(int bonus) {
		this.bonus = bonus;
	}

	public int getBonus() {
		return this.bonus;
	}

	/**
	 * @return the receiverProvince
	 */
	public String getReceiverProvince() {
		return receiverProvince;
	}

	/**
	 * @param receiverProvince the receiverProvince to set
	 */
	public void setReceiverProvince(String receiverProvince) {
		this.receiverProvince = receiverProvince;
	}

	/**
	 * @return the weightSum
	 */
	public String getWeightSum() {
		return weightSum;
	}

	/**
	 * @param weightSum the weightSum to set
	 */
	public void setWeightSum(String weightSum) {
		this.weightSum = weightSum;
	}

	/**
	 * @return the orderPrice
	 */
	public String getOrderPrice() {
		return orderPrice;
	}

	/**
	 * @param orderPrice the orderPrice to set
	 */
	public void setOrderPrice(String orderPrice) {
		this.orderPrice = orderPrice;
	}

	/**
	 * @return the shipfare
	 */
	public float getShipfare() {
		return shipfare;
	}

	/**
	 * @param shipfare the shipfare to set
	 */
	public void setShipfare(float shipfare) {
		this.shipfare = shipfare;
	}

	public String getActionResult() {
		return actionResult;
	}

	public void setActionResult(String actionResult) {
		this.actionResult = actionResult;
	}

	public String getOrderStCode() {
		return orderStCode;
	}

	public void setOrderStCode(String orderStCode) {
		this.orderStCode = orderStCode;
	}

	public Menu getDetailTpMenu() {
		return detailTpMenu;
	}

	public void setDetailTpMenu(Menu detailTpMenu) {
		this.detailTpMenu = detailTpMenu;
	}

	public String getPaymentTpParam() {
		return paymentTpParam;
	}

	public void setPaymentTpParam(String paymentTpParam) {
		this.paymentTpParam = paymentTpParam;
	}

	public void setSupplierApplyService(SupplierApplyService supplierApplyService) {
		this.supplierApplyService = supplierApplyService;
	}

	public SupplierApply getSupplierApply() {
		return supplierApply;
	}

	public void setSupplierApply(SupplierApply supplierApply) {
		this.supplierApply = supplierApply;
	}

	public String getSnapShots() {
		return snapShots;
	}

	public void setSnapShots(String snapShots) {
		this.snapShots = snapShots;
	}

	public String getProdIdParam() {
		return prodIdParam;
	}

	public void setProdIdParam(String prodIdParam) {
		this.prodIdParam = prodIdParam;
	}

	public Menu getLogisticCompMenu() {
		return logisticCompMenu;
	}

	public void setLogisticCompMenu(Menu logisticCompMenu) {
		this.logisticCompMenu = logisticCompMenu;
	}

	public List<OrderHistory> getOrderHistoryList() {
		return this.orderHistoryList;
	}

	public void setOrderHistoryList(List<OrderHistory> orderHistoryList) {
		this.orderHistoryList = orderHistoryList;
	}

	public OrderHistoryService getOrderHistoryService() {
		return this.orderHistoryService;
	}

	public void setOrderHistoryService(OrderHistoryService orderHistoryService) {
		this.orderHistoryService = orderHistoryService;
	}

	public List<Orders> getOldOrders() {
		return oldOrders;
	}

	public void setOldOrders(List<Orders> oldOrders) {
		this.oldOrders = oldOrders;
	}

	public String getLogTp() {
		return logTp;
	}

	public void setLogTp(String logTp) {
		this.logTp = logTp;
	}

	public List<ServiceOrders> getCancelServiceOrders() {
		return cancelServiceOrders;
	}

	public void setCancelServiceOrders(List<ServiceOrders> cancelServiceOrders) {
		this.cancelServiceOrders = cancelServiceOrders;
	}

	public BigDecimal getCodFee() {
		return codFee;
	}

	public void setCodFee(BigDecimal codFee) {
		this.codFee = codFee;
	}

	public String getPaytype() {
		return paytype;
	}

	public void setPaytype(String paytype) {
		this.paytype = paytype;
	}

	public String getNewShipfare() {
		return newShipfare;
	}

	public void setNewShipfare(String newShipfare) {
		this.newShipfare = newShipfare;
	}

	public String getStoreId() {
		return storeId;
	}

	public void setStoreId(String storeId) {
		this.storeId = storeId;
	}

	public Map<String, String> getProvincesMap() {
		return provincesMap;
	}

	public void setProvincesMap(Map<String, String> provincesMap) {
		this.provincesMap = provincesMap;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getReceiverArea() {
		return receiverArea;
	}

	public void setReceiverArea(String receiverArea) {
		this.receiverArea = receiverArea;
	}

	public String getShowCod() {
		return showCod;
	}

	public void setShowCod(String showCod) {
		this.showCod = showCod;
	}

	public String getShowPos() {
		return showPos;
	}

	public void setShowPos(String showPos) {
		this.showPos = showPos;
	}

	/**
	 * @return the errMsg
	 */
	public String getErrMsg() {
		return errMsg;
	}

	/**
	 * @param errMsg the errMsg to set
	 */
	public void setErrMsg(String errMsg) {
		this.errMsg = errMsg;
	}

	public String getOrderDiscount() {
		return orderDiscount;
	}

	public void setOrderDiscount(String orderDiscount) {
		this.orderDiscount = orderDiscount;
	}

}